<?xml version="1.0" encoding="UTF-8"?>
<!-- Júnior Moura
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets" 
      xmlns:t="http://myfaces.apache.org/tomahawk"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:decorate template="/tema/padrao.xhtml">
        <ui:define name="header">
            <script src="../js/jquery.maskMoney.js" type="text/javascript"></script>
            <script>  

                function handleComplete(xhr, status, args) {  
                    if(!args.validationFailed) {  
                        dialog.hide();
                    } 
                };
            </script> 
            <script type="text/javascript">
                jQuery(document).ready(function(){
                    //                jQuery(".valor").maskMoney();
                    jQuery("#form\\:valor").maskMoney();
                    //                jQuery("input[id*='valor']").maskMoney();
                });
            </script>
        </ui:define>
        <ui:define name="centro" >
            <t:saveState value="#{servicoBean.servico}" />
            <h:form id="form" >
                <h:panelGrid columns="3" >
                    <h:outputLabel value="Status do Serviço: " />
                    <h:selectOneMenu id="ativo" 
                                     value="#{servicoBean.servico.ativo}"
                                     required="true"
                                     requiredMessage="Campo obrigatório" >
                        <f:selectItem itemValue="#{true}" itemLabel="Ativo" />
                        <f:selectItem itemValue="#{false}" itemLabel="Inativo" />
                    </h:selectOneMenu>
                    <p:message for="ativo" />

                    <h:outputLabel value="Nome do Serviço: " />
                    <p:inputText id="nome" 
                                 value="#{servicoBean.servico.nome}"
                                 required="true"
                                 requiredMessage="Campo obrigatório" />
                    <p:message for="nome" />

                    <h:outputLabel value="Valor do Serviço: " />
                    <p:inputText id="valor" 
                                 value="#{servicoBean.servico.valor}"
                                 required="true"
                                 requiredMessage="Campo obrigatório"
                                 styleClass="valor"/>
                    <p:message for="valor" />

                    <p:commandButton value="Salvar"
                                     actionListener="#{servicoBean.salvar}"
                                     update="form"
                                     oncomplete="handleComplete(xhr, status, args)" />
                    <p:commandButton value="Cancelar"
                                     immediate="true"
                                     action="/gestao/servicoLista.jsf"
                                     ajax="false" />
                </h:panelGrid>

            </h:form>
        </ui:define>
    </ui:decorate>
</html>




